@echo off
setlocal enabledelayedexpansion

echo ==============================================
echo 开始执行一键提交...
echo ==============================================

echo 1. 正在添加所有修改...
git add .
if %errorlevel% neq 0 (
    echo 错误：添加文件失败，请检查Git是否正确安装或仓库路径是否正确

    exit /b 1
)

echo 2. 检查是否有修改需要提交...
git diff --quiet --exit-code --cached
if %errorlevel% equ 0 (
    echo 提示：没有任何修改需要提交，无需继续操作
    exit /b 0
)

echo 3. 正在提交修改...
set "commitTime=%date:~0,4%-%date:~5,2%-%date:~8,2% %time:~0,2%:%time:~3,2%:%time:~6,2%"
git commit -m "自动提交: !commitTime!"
if %errorlevel% neq 0 (
    echo 错误：提交失败，请检查是否有未解决的冲突或提交信息是否合法

    exit /b 1
)

echo 4. 正在强制推送到远程 master 分支...
git push -f origin master
if %errorlevel% neq 0 (
    echo 错误：推送失败，可能是网络问题或权限不足

    exit /b 1
)

echo ==============================================
echo ✅ 操作完成！所有修改已强制提交到远程
echo ==============================================
